<?php
/**
 * Notes:
 * User:ZSLAA
 * DateTime: 2020/10/29 10:54
 */

namespace app;


class common
{
    //密码加盐加密
    public static function encryption($salt,$value){
        return md5($salt.$value);
    }
    //获取加密盐
    public static function getSalt($length){
        $str = "1234567890asdfghjklqwertyuiopzxcvbnmASDFGHJKLZXCVBNMPOIUYTREWQ";
        return substr(str_shuffle($str),0,$length);
    }

    //登入判断是否登入
    public static function isLogin(){
        //判断session是否存在用户名
        if (empty(session('username'))){
            return false;
        }
        //判断session是否存用户id
        if (empty(session('userid'))){
            return false;
        }

        //判断session是否存在用户昵称
        if (empty(session('nickname'))){
            return false;
        }

        return true;
    }

}